﻿using Abp.Domain.Entities;
using Abp.Domain.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;


namespace ACN.Mail.IRepositories
{

    public interface IRepositoryBase<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
        where TEntity : class, IEntity<TPrimaryKey>
    {
        #region SQL
        List<TEntity> FromSql(string sql, params object[] parameters);
        List<TEntity> FromSql(string sql, IDictionary<string, object> parameters);
        Task<List<TEntity>> FromSqlAsync(string sql, params object[] parameters);
        Task<List<TEntity>> FromSqlAsync(string sql, IDictionary<string, object> parameters);
        
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        int Execute(string sql, params object[] parameters);


        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="parameters"></params>
        /// <returns></returns>
        int Execute(string sql, IDictionary<string, object> parameters);
        #endregion

        #region  Including异步重载
        Task<List<TEntity>> GetAllListAsync(params Expression<Func<TEntity, object>>[] includingPropertys);

        Task<List<TEntity>> GetAllListAsync(Expression<Func<TEntity, bool>> predicate, params Expression<Func<TEntity, object>>[] includingPropertys);

        Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate, params Expression<Func<TEntity, object>>[] includingPropertys);

        Task<TEntity> FirstOrDefaultAsync(TPrimaryKey id, params Expression<Func<TEntity, object>>[] includingPropertys);

        Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate, params Expression<Func<TEntity, object>>[] includingPropertys);
        #endregion
    }

    public interface IRepositoryBase<TEntity> : IRepositoryBase<TEntity, int>
        where TEntity : class, IEntity<int>
    {

    }
}
